import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:testlzhu/page/equipment/rent_page/rent_page_logic.dart';
import 'package:testlzhu/view/custem_bar.dart';
import 'package:testlzhu/view/item_rent.dart';
import 'package:testlzhu/view/search_app_bar.dart';
import 'package:testlzhu/view/smartrefresher.dart';

import 'equipmentsearch_logic.dart';

class EquipmentSearchPage extends StatelessWidget {
  late RefreshController _controller;

  @override
  Widget build(BuildContext context) {
    final logic = Get.find<RentPageLogic>();
    return Scaffold(
      appBar: SearchAppBar(onSubmitted: (str){
        logic.getData( str: str, state: 1);

      },
      canClick: ()=> Get.back(),
      ),

      body: GetBuilder<RentPageLogic>(builder: (logic) {
        return MySmartRefresher(
          itemBuilder: (BuildContext context, int index) {
            return RentItem(data: logic.datas[index]);
          },
          itemCount: (BuildContext context) {
            return logic.datas.length;
          },
          myRefreshController: (RefreshController controller) {
            _controller = controller;
            logic.setController(_controller);
          },
          monRefresh: () {
            logic.getData(state: 1);
          },
          loading: () {
            logic.getData(state: 2);
          },
        );
      }),
    );
  }
}
